var express = require('express');
var router = express.Router();
const banner = require("../sql/banner")
const sql = require("../sql/sql")


/**
* @apiGroup 轮播图信息
* @api {get} /api/banner/get 获取轮播图数据
* @apiVersion 0.0.0
* @apiDescription 获取轮播图数据
* @apiSuccess {number} code 请求状态
* @apiSuccess {string} title 请求说明
* @apiSuccess {array} data 请求数据
* @apiSuccessExample {json} Success-Response:
* {
*    "code":200,
*    "title":"请求成功",
*    "data":[{},{},...]
* }
* @apiError {number} code 请求状态
* @apiError {string} title 请求说明
* @apiError {array} data 请求数据
* @apiErrorExample {json} Error-Response:
* {
*    "code":201,
*    "title":"请求失败",
*    "data":"NOT DATA"
* }
* @apiSampleRequest http://localhost:3000/api/banner/get
*/
router.get('/get', function(req, res, next) {
  // 1. 请求数据库中的数据
  sql.get({
    colName:banner
  }).then(data=>{
    res.send({
      code:200,
      title:"获取成功",
      data:data
    })
  }).catch((err)=>{
    res.send({
      code:201,
      title:"获取失败",
      data:err
    })
  })
});

module.exports = router;
